<template>
    <div>
        <top-bar></top-bar>
        <left-bar :datas='data'></left-bar>
        <div class="system">
            <home-bar :currentPage='currentPage'></home-bar>
            <div class="order-main system-main">
                <div class="main-position">
                    首页 > 资讯中心
                    <a href="javascript:void(0);"><i class="el-icon-refresh"></i></a>
                </div>
                <div class="main-height"></div>
                <div class="main-mains">
                    <div class="clear main-mains-main1">
                        <div class="clear main-mains1">
                            <div class="main-mains-top clear">
                                <span class="fl" style="margin-left:20px;">平台公告</span>
                                <router-link to="/relationsList/0">
                                    <span class="fr active">更多 ></span>
                                </router-link>
                            </div>
                            <div class="fl w50 main-mains-txt" style="border-left:0px;height:180px;">
                                <ul>
                                    <li v-for="(item,index) in dataList1" :key="index">
                                        <router-link :to="{name:'detailstxt',params:{id:item.id}}">{{item.title}}</router-link><span class="fr">{{item.update_time | times}}</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="clear main-mains-main1">
                        <div class="clear main-mains1">
                            <div class="fl w50 main-mains-txt">
                                <div class="main-mains-top clear">
                                    <span class="fl">医疗咨询</span>
                                    <router-link to="/relationsList/1">
                                        <span class="fr active">更多 ></span>
                                    </router-link>
                                </div>
                                <ul>
                                    <li v-for="(item,index) in dataList2" :key="index">
                                        <router-link :to="{name:'detailstxt',params:{id:item.id}}">{{item.title}}</router-link><span class="fr">{{item.update_time | times}}</span>
                                    </li>
                                </ul>
                            </div>
                            <div class="fl w50 main-mains-txt">
                                <div class="main-mains-top clear">
                                    <span class="fl">常见问题</span>
                                    <router-link to="/relationsList/4" >
                                        <span class="fr active">更多 ></span>
                                    </router-link>
                                </div>
                                <ul>
                                    <li v-for="(item,index) in dataList3" :key="index">
                                        <router-link :to="{name:'detailstxt',params:{id:item.id}}">{{item.title}}</router-link><span class="fr">{{item.update_time | times}}</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="clear main-mains-main1">
                        <div class="clear main-mains1">
                            <div class="fl w50 main-mains-txt">
                                <div class="main-mains-top clear">
                                    <span class="fl">商学院</span>
                                    <router-link to="/relationsList/2">
                                        <span class="fr active">更多 ></span>
                                    </router-link>
                                </div>
                                <ul>
                                    <li v-for="(item,index) in dataList4" :key="index">
                                        <router-link :to="{name:'detailstxt',params:{id:item.id}}">{{item.title}}</router-link><span class="fr">{{item.update_time | times}}</span>
                                    </li>
                                </ul>
                            </div>
                            <div class="fl w50 main-mains-txt">
                                <div class="main-mains-top clear">
                                    <span class="fl">安全保障</span>
                                    <router-link to="/relationsList/3" >
                                        <span class="fr active">更多 ></span>
                                    </router-link>
                                </div>
                               <ul>
                                    <li v-for="(item,index) in dataList5" :key="index">
                                        <router-link :to="{name:'detailstxt',params:{id:item.id}}">{{item.title}}</router-link><span class="fr">{{item.update_time | times}}</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import topBar from "../public/top";
import leftBar from "../public/left";
import homeBar from "../public/homebar";
export default {
  components: {
    leftBar,
    topBar,
    homeBar
  },
  data() {
    return {
      data: "/relations",
      currentPage: {
        path: "/relations",
        name: "资讯中心"
      },
      dataList1: [],
      dataList2: [],
      dataList3: [],
      dataList4: [],
      dataList5: []
    };
  },
  methods: {
    addPath(n1, n2) {
      //点击切换home-bar
      var obj = {};
      obj.n1 = n1;
      obj.n2 = n2;
      this.$store.commit("addPath", obj);
    },
    dataList() {
      //获取咨询数据
      let _this = this;
      let ourls =
        this.urls +
        "/who/user/refreshToken/" +
        localStorage.getItem("uid") +
        "/" +
        localStorage.getItem("token");
      checkTime(
        new Date().getTime() / 1000,
        ourls,
        localStorage.getItem("reToken")
      );
      _this
        .$http({
          url:
            _this.urls +
            "/who/Article/getList/" +
            localStorage.getItem("uid") +
            "/" +
            localStorage.getItem("token"),
          method: "post",
          data: {}
        })
        .then(function(res) {
          let data = res.data;
          if (data.code == "1") {
            _this.dataList1 = data.data[0];
            _this.dataList2 = data.data[1];
            _this.dataList3 = data.data[4];
            _this.dataList4 = data.data[2];
            _this.dataList5 = data.data[3];
          } else {
            invalid(data.msg);
            _this.$message.error(data.msg);
          }
        })
        .catch(function(error) {
          console.log(error);
        });
    }
  },
  activated() {
    this.dataList();
  },
  filters: {
    times(value) {
      var time = new Date(value * 1000);
      var month =
        time.getMonth() + 1 > 9
          ? time.getMonth() + 1
          : "0" + (time.getMonth() + 1);
      var data = time.getDate() > 9 ? time.getDate() : "0" + time.getDate();
      var hour = time.getHours() > 9 ? time.getHours() : "0" + time.getHours();
      var minutes =
        time.getMinutes() > 9 ? time.getMinutes() : "0" + time.getMinutes();
      var second =
        time.getSeconds() > 9 ? time.getSeconds() : "0" + time.getSeconds();
      var times =
        time.getFullYear() +
        "-" +
        month +
        "-" +
        data +
        " " +
        hour +
        ":" +
        minutes +
        ":" +
        second;
      return times;
    }
  }
};
</script>

<style lang="less">
@import "relations.less";
</style>
